/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package test.entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Issam
 */
@Entity
@Table(name = "TRADER_GRADE", catalog = "", schema = "NETTRADING")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TraderGrade.findAll", query = "SELECT t FROM TraderGrade t"),
    @NamedQuery(name = "TraderGrade.findByMatricule", query = "SELECT t FROM TraderGrade t WHERE t.traderGradePK.matricule = :matricule"),
    @NamedQuery(name = "TraderGrade.findByIdGrade", query = "SELECT t FROM TraderGrade t WHERE t.traderGradePK.idGrade = :idGrade"),
    @NamedQuery(name = "TraderGrade.findByDateDebut", query = "SELECT t FROM TraderGrade t WHERE t.dateDebut = :dateDebut"),
    @NamedQuery(name = "TraderGrade.findByDateFin", query = "SELECT t FROM TraderGrade t WHERE t.dateFin = :dateFin")})
public class TraderGrade implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected TraderGradePK traderGradePK;
    @Basic(optional = false)
    @Column(name = "DATE_DEBUT", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateDebut;
    @Basic(optional = false)
    @Column(name = "DATE_FIN", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateFin;
    @JoinColumn(name = "MATRICULE", referencedColumnName = "MATRICULE", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Trader trader;
    @JoinColumn(name = "ID_GRADE", referencedColumnName = "ID_GRADE", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Grade grade;

    public TraderGrade() {
    }

    public TraderGrade(TraderGradePK traderGradePK) {
        this.traderGradePK = traderGradePK;
    }

    public TraderGrade(TraderGradePK traderGradePK, Date dateDebut, Date dateFin) {
        this.traderGradePK = traderGradePK;
        this.dateDebut = dateDebut;
        this.dateFin = dateFin;
    }

    public TraderGrade(short matricule, short idGrade) {
        this.traderGradePK = new TraderGradePK(matricule, idGrade);
    }

    public TraderGradePK getTraderGradePK() {
        return traderGradePK;
    }

    public void setTraderGradePK(TraderGradePK traderGradePK) {
        this.traderGradePK = traderGradePK;
    }

    public Date getDateDebut() {
        return dateDebut;
    }

    public void setDateDebut(Date dateDebut) {
        this.dateDebut = dateDebut;
    }

    public Date getDateFin() {
        return dateFin;
    }

    public void setDateFin(Date dateFin) {
        this.dateFin = dateFin;
    }

    public Trader getTrader() {
        return trader;
    }

    public void setTrader(Trader trader) {
        this.trader = trader;
    }

    public Grade getGrade() {
        return grade;
    }

    public void setGrade(Grade grade) {
        this.grade = grade;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (traderGradePK != null ? traderGradePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TraderGrade)) {
            return false;
        }
        TraderGrade other = (TraderGrade) object;
        if ((this.traderGradePK == null && other.traderGradePK != null) || (this.traderGradePK != null && !this.traderGradePK.equals(other.traderGradePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "test.entities.TraderGrade[ traderGradePK=" + traderGradePK + " ]";
    }
    
}
